home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / clients / xbiff / xbiff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-12  |  3.7 KB  |  120 lines

  1. /*
  2.  * $XConsortium: xbiff.c,v 1.17 91/01/10 14:25:32 gildea Exp $
  3.  *
  4.  * Copyright 1988 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted, provided
  8.  * that the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * Author:  Jim Fulton, MIT X Consortium
  17.  */
  18.  
  19. #include <stdio.h>
  20. #include <X11/Xatom.h>
  21. #ifdef MSDOS
  22. #include "X11/Intrinsc.h"      /* QDK 05/11/1994  2:47pm. */
  23. #else
  24. #include "X11/Intrinsic.h"
  25. #endif
  26. #include <X11/StringDefs.h>
  27. #include <X11/Xaw/Mailbox.h>
  28. #include <X11/Xaw/Cardinals.h>
  29.  
  30. #ifndef MSDOS
  31. extern void exit();
  32. #endif
  33.  
  34. static void quit();
  35.  
  36. char *ProgramName;
  37.  
  38. static XrmOptionDescRec options[] = {
  39. { "-update", "*mailbox.update", XrmoptionSepArg, (caddr_t) NULL },
  40. { "-file",   "*mailbox.file", XrmoptionSepArg, (caddr_t) NULL },
  41. { "-volume", "*mailbox.volume", XrmoptionSepArg, (caddr_t) NULL },
  42. { "-shape",  "*mailbox.shapeWindow", XrmoptionNoArg, (caddr_t) "on" },
  43. };
  44.  
  45. static XtActionsRec xbiff_actions[] = {
  46.     { "quit", quit },
  47. };
  48. static Atom wm_delete_window;
  49.  
  50. static void Usage ()
  51. {
  52.     static char *help_message[] = {
  53. "where options include:",
  54. "    -display host:dpy              X server to contact",
  55. "    -geometry geom                 size of mailbox",
  56. "    -file file                     file to watch",
  57. "    -update seconds                how often to check for mail",
  58. "    -volume percentage             how loud to ring the bell",
  59. "    -bg color                      background color",
  60. "    -fg color                      foreground color",
  61. "    -rv                            reverse video",
  62. "    -shape                         shape the window",
  63. NULL};
  64.     char **cpp;
  65.  
  66.     fprintf (stderr, "usage:  %s [-options ...]\n", ProgramName);
  67.     for (cpp = help_message; *cpp; cpp++) {
  68.     fprintf (stderr, "%s\n", *cpp);
  69.     }
  70.     fprintf (stderr, "\n");
  71.     exit (1);
  72. }
  73.  
  74.  
  75. void main (argc, argv)
  76.     int argc;
  77.     char **argv;
  78. {
  79.     XtAppContext xtcontext;
  80.     Widget toplevel, w;
  81.  
  82.     ProgramName = argv[0];
  83.  
  84.     toplevel = XtAppInitialize(&xtcontext, "XBiff", options, XtNumber (options),
  85.                    &argc, argv, NULL, NULL, 0);
  86.     if (argc != 1) Usage ();
  87.  
  88.     /*
  89.      * This is a hack so that f.delete will do something useful in this
  90.      * single-window application.
  91.      */
  92.     XtAppAddActions (xtcontext, xbiff_actions, XtNumber(xbiff_actions));
  93.     XtOverrideTranslations(toplevel,
  94.            XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()"));
  95.  
  96.     w = XtCreateManagedWidget ("mailbox", mailboxWidgetClass, toplevel,
  97.                    NULL, 0);
  98.     XtRealizeWidget (toplevel);
  99.     wm_delete_window = XInternAtom (XtDisplay(toplevel), "WM_DELETE_WINDOW",
  100.                                     False);
  101.     (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
  102.                             &wm_delete_window, 1);
  103.     XtAppMainLoop (xtcontext);
  104. }
  105.  
  106. static void quit (w, event, params, num_params)
  107.     Widget w;
  108.     XEvent *event;
  109.     String *params;
  110.     Cardinal *num_params;
  111. {
  112.     if (event->type == ClientMessage &&
  113.         event->xclient.data.l[0] != wm_delete_window) {
  114.         XBell (XtDisplay(w), 0);
  115.         return;
  116.     }
  117.     XCloseDisplay (XtDisplay(w));
  118.     exit (0);
  119. }
  120.